package com.xiaoying.chuguoliuxue;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;

public class VisaSolutionActivity extends BaseActivity {

    @BindView(R.id.rcv_content_list)
    RecyclerView rcvContentList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitle(getString(R.string.visa_solution));
        setLeftTitleImage(R.mipmap.ic_arrow_white);
        rcvContentList.setAdapter(new ItemAdapter());
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_visa_solution;
    }

    private final class ItemAdapter extends RecyclerView.Adapter<ItemViewHolder> {


        @Override
        public ItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View itemView = LayoutInflater.from(parent.getContext())
                    .inflate(R.layout.item_visa_solution, parent, false);
            return new ItemViewHolder(itemView);
        }

        @Override
        public void onBindViewHolder(ItemViewHolder holder, int position) {
            if ((position + 1) == getItemCount()) {
                holder.line.setVisibility(View.INVISIBLE);
            } else {
                holder.line.setVisibility(View.VISIBLE);
            }
            holder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    time2000();
                }
            });

            switch (position) {
                case 0:
                    holder.logo.setImageResource(R.mipmap.ic_t4);
                    break;

                case 1:
                    holder.logo.setImageResource(R.mipmap.ic_t5);
                    break;

                case 2:
                    holder.logo.setImageResource(R.mipmap.ic_t6);
                    break;
            }

        }

        @Override
        public int getItemCount() {
            return 3;
        }
    }

    static class ItemViewHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.logo)
        ImageView logo;
        @BindView(R.id.textView2)
        TextView textView2;
        @BindView(R.id.textView3)
        TextView textView3;
        @BindView(R.id.textView4)
        TextView textView4;
        @BindView(R.id.textView5)
        TextView textView5;
        @BindView(R.id.textView6)
        TextView textView6;
        @BindView(R.id.line)
        View line;

        ItemViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }

}
